//
//  HomeDIsViewController.swift
//  SwiftDemo
//
//  Created by admin on 2020/10/15.
//

import UIKit

class HomeDIsViewController: RootViewController {
    var homeDisId: Int?
    var originViewHeight: CGFloat?

    var ringingBlock: ((_ ringLink: String) -> Void)?

    var bacBtn: UIButton!

    // MARK: - Common

    let ScreenWidth = UIScreen.main.bounds.size.width
    let ScreenHeight = UIScreen.main.bounds.size.height
    let HomeIndicatorHeight: CGFloat = 0
    let TabBarHeight: CGFloat = 49

    func isiPhoneX() -> Bool {
        let screenHeight = UIScreen.main.nativeBounds.size.height
        if screenHeight == 2436 || screenHeight == 1792 || screenHeight == 2688 || screenHeight == 1624 {
            return true
        }
        return false
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        print("跳界面传值----\(homeDisId ?? 0)")

        let sc_w: Int = 50

        bacBtn = UIButton()
        bacBtn?.frame = CGRect(x: sc_w, y: 300, width: Int(SCREEN_WIDTH) - sc_w * 2, height: 50)
        bacBtn?.backgroundColor = UIColor.red
        bacBtn?.setTitle("返回传值", for: .normal)
        bacBtn?.addTarget(self, action: #selector(backBlcok), for: UIControl.Event.touchUpInside)

        view.addSubview(bacBtn!)
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "点击", style: .plain, target: self, action: #selector(cilckRightBar))

        navigationItem.rightBarButtonItem!.tintColor = UIColor.red
//        UITabBar.appearance().tintColor = UIColor.red
//        UINavigationBar.appearance().tintColor = UIColor.red
    }

    @objc func cilckRightBar()  {

        print("点击")
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(true)
        tabBarController?.tabBar.isHidden = true
        originViewHeight = view.frame.size.height
        tabBarController?.tabBar.isHidden = true
        view.frame.size.height += TabBarHeight
        view.frame.size.height += HomeIndicatorHeight
    }

    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        view.frame.size.height -= HomeIndicatorHeight
    }

    // 返回传值
    @objc func backBlcok() {
        super.popToPrepare()
        self.ringingBlock!("点我返回上一页并传值");
    }
}

extension HomeDIsViewController {
}
